(* Solução de Ax=b para A triangular superior e invertível *)

A={{1,0,2},{0,2,-3},{0,0,1/2}};
b={1,-2,0};

If[Det[A]==0,Print["Not invertible"]]
MatrixForm[A]
MatrixForm[b]
d=Length[b];

x=Table[0,{i,d}];
x[[d]]=b[[d]]/A[[d,d]];

For[i=d-1,i≥1,i--,
x[[i]]=(b[[i]]-Sum[A[[i,j]] x[[j]],{j,i+1,d}])/A[[i,i]];
]

MatrixForm[x]